(async function(){
    var list = getNode("table");
    var line = list.children[0];
    clearAll(list);
    for(var i=0;i<publicParam.voteList.length;i++){
        var v = publicParam.voteList[i];
        var newLine = line.cloneNode(true);
        list.appendChild(newLine);
        //关联小组
        if (v.groupId.toNumber()!=0){
            var group = getSubNode(newLine,"group");
            var g = await getGroup(v.groupId);
            group.tag = g;
            group.innerText = shortName(g.name);
            group.onclick = function(){
                goto("group/detail",this.tag);
            };
        }
        //点击组名查看详细信息
        var name = getSubNode(newLine,"name");
        name.innerText = shortName(v.name);
        name.tag = v;
        name.onclick = function(){
            goto("vote/detail",this.tag);
        };
        //组ID
        var voteId = getSubNode(newLine,"voteId");
        voteId.innerText = v.id.toNumber();
        //发起人
        var member = getSubNode(newLine,"member");
        var m = getMemberByAddress(v.promoter);
        member.innerText = m.name;
        member.tag = m.address;
        //让会员名可以点击，进入详细页面进行操作
        member.onclick=function(){
            goto("member/info",this.tag);
        }
        //结束时间
        var end = getSubNode(newLine,"end");
        end.innerText = timeFormat(v.end);
        var voted = getSubNode(newLine,"voted");
        voted.innerText = v.voters.length;
    }
})();